import {
	ref,
	watch
} from 'vue'

export default function(_userInfo) {
	let dateShow = ref(false)


	// 
	let currentDate = ref(['2021', '01', '01']);


	// ['2021', '01', '01']


	watch(_userInfo, function(n) {

		console.log(n)

		if (n.birthday) {
			currentDate = n.birthday.split('/')
		}
	}, {
		immediate: true
	})




	function showDatePopup() {
		dateShow.value = true
	}

	function hideDatePopup() {
		dateShow.value = false
	}

	function datecConfirm(e) {

		currentDate.value = e.selectedValues;

		_userInfo.value.birthday = e.selectedValues.join('/')

		dateShow.value = false
	}


	return {
		showDatePopup,
		hideDatePopup,
		datecConfirm,
		dateShow,
		minDate: new Date(1930, 0, 1),
		maxDate: new Date(2025, 5, 1),
		currentDate
	}

}